import { defineStore } from 'pinia'
const useUserStore = defineStore('user', {
  state: () => {
    return {
      userName: 'hello'
    }
  },
  getters: {},
  actions: {
    updateName(newName) {
      this.userName = newName
    }
  },
  // persist: true // 默认本地localstorage
  persist: {
    key: 'myUser',
    storage: sessionStorage, // localStorage
    paths: ['userName'] // 空数组是都不存储，null或undefined时为存储所有，填写值时存储当前值
  }
})

export default useUserStore
